<template>
  <div class="app-container allocate-fixed">
    <div class="main-content">
      <!-- 左侧内容区域 -->
      <div class="left-content">
        <!-- 搜索条件卡片 -->
        <el-card class="search-card" shadow="hover">
          <div slot="header" class="clearfix">
            <span><i class="el-icon-search"></i> 搜索条件</span>
            <el-button style="float: right; padding: 3px 0" type="text" @click="toggleSearch">
              {{ showSearch ? '收起' : '展开' }}
            </el-button>
          </div>

          <el-form
            :model="queryParams"
            ref="queryForm"
            size="small"
            :inline="false"
            v-show="showSearch"
            label-width="80px"
            class="search-form-grid"
          >
            <el-row :gutter="20">
              <el-col :xs="24" :sm="12" :md="8">
                <el-form-item label="订单号" prop="orderIdView">
                  <el-input v-model="queryParams.orderIdView" placeholder="请输入订单号" clearable
                            @keyup.enter.native="handleQuery"/>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :sm="12" :md="8">
                <el-form-item label="游戏名" prop="gameName">
                  <el-select v-model="queryParams.gameName" placeholder="请选择游戏名" clearable filterable
                             @change="handleQuery" style="width: 100%">
                    <el-option v-for="item in gameNameOptions" :key="item" :label="item" :value="item"/>
                  </el-select>
                </el-form-item>
              </el-col>
              <!--              <el-col :xs="24" :sm="12" :md="8">-->
              <!--                <el-form-item label="状态" prop="orderSta">-->
              <!--                  <el-select v-model="queryParams.orderSta" placeholder="请选择状态" clearable style="width: 100%">-->
              <!--                    <el-option v-for="dict in dict.type.order_sta" :key="dict.value" :label="dict.label" :value="dict.value" />-->
              <!--                  </el-select>-->
              <!--                </el-form-item>-->
              <!--              </el-col>-->
              <el-col :xs="24" :sm="12" :md="8">
                <el-form-item label="游戏内容" prop="project">
                  <el-input v-model="queryParams.project" placeholder="请输入代练/陪玩内容" clearable
                            @keyup.enter.native="handleQuery"/>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :sm="12" :md="8">
                <el-form-item label="打手编号" prop="jiwei">
                  <el-input v-model="queryParams.jiwei" placeholder="请输入打手编号" clearable
                            @keyup.enter.native="handleQuery"/>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :sm="12" :md="8" class="search-btn-col">
                <el-form-item>
                  <div class="search-btn-group">
                    <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                    <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">刷新</el-button>
                    <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
                               v-hasPermi="['order:info:export']">导出
                    </el-button>
                  </div>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </el-card>

        <!-- 订单列表卡片 -->
        <el-card class="order-list-card" shadow="hover">
          <div slot="header" class="clearfix">
            <span><i class="el-icon-document"></i> 自动派单订单列表</span>
            <span style="float: right; color: #909399; font-size: 12px;">
                共 {{ total }} 条记录
            </span>
          </div>
          <div class="order-table-wrapper">
            <el-table
              v-loading="loading"
              :data="allocateList"
              @selection-change="handleSelectionChange"
              stripe
              border
            >
              <el-table-column label="序号" type="index" width="50" align="center"/>
              <el-table-column label="订单号" align="center" prop="orderIdView" width="160">
                <template slot-scope="scope">
                  <el-tooltip class="item" effect="dark" :content="scope.row.orderIdView" placement="top">
                    <div
                      class="order-id-cell"
                      @click="copyText(scope.row.orderIdView)"
                    >
                      {{ scope.row.orderIdView }}
                    </div>
                  </el-tooltip>
                </template>
              </el-table-column>
              <el-table-column label="游戏名" align="center" prop="gameName" width="120"/>
              <el-table-column label="代练/陪玩内容" align="center" prop="project" min-width="150">
                <template slot-scope="scope">
                  <el-tooltip class="item" effect="dark" :content="scope.row.project" placement="top">
                    <div class="project-cell">
                      {{ scope.row.project }}
                    </div>
                  </el-tooltip>
                </template>
              </el-table-column>
              <el-table-column label="状态" align="center" prop="orderSta" width="80">
                <template slot-scope="scope">
                  <dict-tag :options="dict.type.order_sta" :value="scope.row.orderSta"/>
                </template>
              </el-table-column>
              <el-table-column label="发单价" align="center" prop="recFee" width="80"/>
              <el-table-column label="接单价" align="center" prop="price" width="80"/>
              <el-table-column label="录单时间" align="center" prop="assTime" width="120">
                <template slot-scope="scope">
                  <span>{{ parseTime(scope.row.assTime, '{h}:{m}:{s}') }}</span>
                </template>
              </el-table-column>
              <el-table-column label="打手编号" align="center" prop="jiwei" width="80"/>
            </el-table>
          </div>
          <div class="pagination-wrapper">
            <pagination
              v-show="total>0"
              :total="total"
              :page.sync="queryParams.pageNum"
              :limit.sync="queryParams.pageSize"
              @pagination="getList"
              style="margin-top: 15px; margin-bottom: 10px;"
            />
          </div>
        </el-card>
      </div>

      <!-- 右侧工具栏 -->
      <div class="right-toolbar">
        <el-card class="toolbar-card" shadow="hover">
          <div slot="header" class="clearfix">
            <span><i class="el-icon-user-solid"></i> 指派打手</span>
          </div>

          <div class="toolbar-content" v-loading="rightLoading" element-loading-text="数据请求中...">
            <!-- 指派表单 -->
            <el-card shadow="never" class="assign-form-card">
              <div slot="header" class="clearfix">
                <span>指派信息</span>
              </div>
              <el-form :inline="false" label-width="80px" size="small" class="assign-form-beauty">
                <el-form-item label="订单编号">
                  <el-input
                    v-model="takeOrder.id"
                    placeholder="请输入订单编号"
                    clearable
                    style="width: 100%;"
                    prefix-icon="el-icon-document"
                  />
                </el-form-item>
                <el-form-item label="打手编号">
                  <el-input
                    v-model="takeOrder.workerId"
                    placeholder="请输入打手编号"
                    clearable
                    style="width: 100%;"
                    prefix-icon="el-icon-user"
                  >
                    <el-select v-model="selectedUser" slot="prepend" placeholder="请选择用户" @change="handleUserChange"
                               style="width: 80px;">
                      <el-option
                        v-for="user in userList"
                        :key="user.userId"
                        :label="user.userName"
                        :value="user.userId"
                      >
                        <span>{{ user.userName }}</span>
                        <!--                        <span style="float: right; color: #8492a6; font-size: 13px">{{ user.nickName }}</span>-->
                      </el-option>
                    </el-select>
                  </el-input>
                </el-form-item>
              </el-form>
            </el-card>

            <!-- 搜索结果 -->
            <el-card class="search-result-card" :body-style="{padding: '0'}" shadow="never">
              <div slot="header" class="clearfix">搜索订单结果</div>
              <el-descriptions :column="1" size="small" border
                               :label-style="{width: '60px', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis'}">
                <el-descriptions-item label="订单号">
                  <span class="result-text">{{ searchResult.orderIdView || '暂无数据' }}</span>
                </el-descriptions-item>
                <el-descriptions-item label="游戏名">
                  <span class="result-text">{{ searchResult.gameName || '暂无数据' }}</span>
                </el-descriptions-item>
                <el-descriptions-item label="发单价">
                  <span class="result-text">{{ searchResult.recFee || '暂无数据' }}</span>
                </el-descriptions-item>
                <el-descriptions-item label="任务内容">
                  <el-tooltip class="item" effect="dark" :content="searchResult.project || '暂无数据'" placement="top">
                    <span class="result-text multi-ellipsis">{{ searchResult.project || '暂无数据' }}</span>
                  </el-tooltip>
                </el-descriptions-item>
                <el-descriptions-item label="状态">
                  <el-tag size="mini" :type="searchResult.orderSta ? 'success' : 'info'">
                    {{ searchResult.orderSta || '未知' }}
                  </el-tag>
                </el-descriptions-item>
                <el-descriptions-item label="游戏区服">
                  <span class="result-text">{{ searchResult.gameArea || '暂无数据' }}</span>
                </el-descriptions-item>
                <el-descriptions-item label="注意事项">
                  <span class="result-text">{{ searchResult.message || '确定好游戏内容可接单,接单不退！！！' }}</span>
                </el-descriptions-item>
              </el-descriptions>
            </el-card>

            <!-- 分配结果 -->
            <el-card class="assign-result-card" :body-style="{padding: '0'}" shadow="never">
              <div slot="header" class="clearfix">接单结果</div>
              <el-descriptions :column="1" size="small" border
                               :label-style="{width: '60px', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis'}">
                <el-descriptions-item label="订单消息">
                  <el-tooltip class="item" effect="dark" :content="assignResult.takeOrderMsg || '暂无数据'"
                              placement="top">
                    <span class="result-text single-ellipsis">{{ assignResult.takeOrderMsg || '暂无数据' }}</span>
                  </el-tooltip>
                </el-descriptions-item>
                <el-descriptions-item label="状态">
                  <el-tag size="mini" :type="assignResult.allocateMsg ? 'success' : 'info'">
                    {{ assignResult.allocateMsg || '未知' }}
                  </el-tag>
                </el-descriptions-item>
                <el-descriptions-item label="打手收益">
                  <span class="result-text">{{ assignResult.allocatePrice || '暂无数据' }}</span>
                </el-descriptions-item>
              </el-descriptions>
            </el-card>

            <!-- 操作按钮 -->
            <div class="assign-actions">
              <el-button
                type="primary"
                icon="el-icon-search"
                @click="handleSearchOrder"
                :loading="rightLoading"
                style="width: 100%;"
              >
                搜索订单
              </el-button>
              <el-button
                type="success"
                icon="el-icon-check"
                @click="handleAssignOrder"
                :loading="rightLoading"
                style="width: 100%;"
              >
                确认指派
              </el-button>
            </div>
          </div>
        </el-card>
      </div>
    </div>

    <!-- 添加或修改数据汇总对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="系统内置单号" prop="orderId">
              <el-input v-model="form.orderId" placeholder="请输入系统内置单号"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="订单号" prop="orderIdView">
              <el-input v-model="form.orderIdView" placeholder="请输入订单号"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="游戏名" prop="gameName">
              <el-input v-model="form.gameName" placeholder="请输入游戏名"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="状态" prop="orderSta">
              <el-select v-model="form.orderSta" placeholder="请选择状态" style="width: 100%">
                <el-option
                  v-for="dict in dict.type.order_sta"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="代练/陪玩内容" prop="project">
          <el-input v-model="form.project" type="textarea" placeholder="请输入代练/陪玩内容"/>
        </el-form-item>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="接手人" prop="recManName">
              <el-input v-model="form.recManName" placeholder="请输入接手人"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="发单人" prop="assUserName">
              <el-input v-model="form.assUserName" placeholder="请输入发单人"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="发单价" prop="recFee">
              <el-input v-model="form.recFee" placeholder="请输入发单价"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="接单价" prop="price">
              <el-input v-model="form.price" placeholder="请输入接单价"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="录单时间" prop="assTime">
              <el-date-picker
                clearable
                v-model="form.assTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请选择录单时间"
                style="width: 100%"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="机位/团长" prop="jiwei">
              <el-input v-model="form.jiwei" placeholder="请输入机位/团长"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="结算状态" prop="isSettStatus">
          <el-select v-model="form.isSettStatus" placeholder="请选择结算状态" style="width: 100%">
            <el-option
              v-for="dict in dict.type.is_sett_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="重要备注" prop="orderRemark">
          <el-input v-model="form.orderRemark" type="textarea" placeholder="请输入重要备注"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listAllocate,
  getAllocate,
  delAllocate,
  addAllocate,
  updateAllocate,
  getOrderInfo,
  takeOrder
} from "@/api/order/allocate"
import {gameType} from "@/api/order/info";
import {listUser} from "@/api/system/user";

export default {
  name: "Allocate",
  dicts: ['order_sta', 'is_sett_status'],
  data() {
    return {
      rightLoading: false, // 独立给右侧工具栏使用
      takeOrder: {
        id: null,
        workerId: null
      },
      workerIdPre: null, // 打手编号前缀选择
      userList: [], // 用户列表
      selectedUser: null, // 选中的用户
      assignResult: {
        takeOrderMsg: null,
        allocateMsg: null,
        setUserMsg: null,
        updateOrderStatusMsg: null,
        allocatePrice: null
      },
      viewId: null,
      searchResult: {
        orderViewId: null,
        gameArea: null,
        gameName: null,
        project: null,
        status: null,
        message: null,
        recFee: null
      },
      gameNameOptions: [],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 订单指派表格数据
      allocateList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 机位/团长时间范围
      daterangeAssTime: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        gameName: null,
        project: null,
        orderSta: null,
        recManName: null,
        recFee: null,
        price: null,
        isSettStatus: null,
        assUserName: null,
        assTime: null,
        jiwei: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        orderId: [
          {required: true, message: "系统内置单号不能为空", trigger: "blur"}
        ],
      },
    }
  },
  created() {
    this.getGameType()
    this.getList()
    this.getUserList()
  },
  methods: {
    // 切换搜索条件显示
    toggleSearch() {
      this.showSearch = !this.showSearch;
    },

    async handleSearchOrder() {
      if (!this.takeOrder.id) {
        this.$message.warning("订单编号不能为空！");
        return;
      }
      this.searchResult = {
        orderViewId: null,
        gameArea: null,
        gameName: null,
        project: null,
        status: null,
        message: null
      };
      this.rightLoading = true; // 独立右侧遮罩
      try {
        const response = await getOrderInfo(this.takeOrder.id);
        this.searchResult = response.data;
        this.$message.success("获取订单信息成功！");
      } catch (error) {
        console.error("搜索订单异常", error);
      } finally {
        this.rightLoading = false;
      }
    },

    async handleAssignOrder() {
      if (!this.takeOrder.id) {
        this.$message.warning("订单编号不能为空！");
        return;
      }
      if (!this.takeOrder.workerId) {
        this.$message.warning("打手编号不能为空！");
        return;
      }

      // 在提交时拼接选择框的用户ID
      let finalWorkerId = this.takeOrder.workerId;
      if (this.selectedUser) {
        const selectedUser = this.userList.find(user => user.userId === this.selectedUser);
        if (selectedUser) {
          finalWorkerId = selectedUser.userId + "_" + this.takeOrder.workerId;
        }
      }

      this.assignResult = {
        takeOrderMsg: null,
        allocateMsg: null,
        setUserMsg: null,
        updateOrderStatusMsg: null
      };
      this.rightLoading = true; // 独立右侧遮罩
      try {
        const submitData = {
          ...this.takeOrder,
          workerId: finalWorkerId
        };
        const response = await takeOrder(submitData);
        this.assignResult = response.data;
        this.$message.success("指派成功！");
      } catch (error) {
        console.error("指派异常", error);
        this.$message.error("指派失败，请重试！");
      } finally {
        this.rightLoading = false;
      }
    },

    getGameType() {
      gameType().then(response => {
        this.gameNameOptions = response;
      }).catch(error => {
        this.$message.error("获取游戏类型失败！");
        console.error(error);
      });
    },

    // 获取用户列表
    getUserList() {
      listUser({}).then(response => {
        this.userList = response.rows || [];
        // 默认选择第一个用户
        if (this.userList.length > 0) {
          this.selectedUser = this.userList[0].userId;
          // 不设置输入框内容，只设置选择框
          this.takeOrder.workerId = '';
        }
      }).catch(error => {
        this.$message.error("获取用户列表失败！");
        console.error(error);
      });
    },

    // 处理用户选择变化
    handleUserChange(userId) {
      // 只更新选择框，不修改输入框内容
      this.selectedUser = userId;
    },

    // 文本复制
    copyText(text) {
      navigator.clipboard.writeText(text).then(() => {
        this.$message.success('已复制订单号');
      }).catch(() => {
        this.$message.error('复制失败，请手动复制');
      });
    },

    /** 查询订单指派列表 */
    getList() {
      this.loading = true;
      this.queryParams.params = {};
      if (this.daterangeAssTime != null && this.daterangeAssTime !== '') {
        this.queryParams.params["beginAssTime"] = this.daterangeAssTime[0];
        this.queryParams.params["endAssTime"] = this.daterangeAssTime[1];
      }
      listAllocate(this.queryParams).then(response => {
        this.allocateList = response.rows;
        this.total = response.total;
      }).finally(() => {
        this.loading = false;
      });
    },

    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },

    // 表单重置
    reset() {
      this.form = {
        id: null,
        orderId: null,
        orderIdView: null,
        gameName: null,
        project: null,
        orderSta: null,
        recManName: null,
        recFee: null,
        price: null,
        isSettStatus: null,
        assUserName: null,
        assTime: null,
        jiwei: null,
        orderRemark: null,
        createTime: null,
        updateTime: null
      };
      this.resetForm("form");
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },

    /** 重置按钮操作 */
    resetQuery() {
      this.daterangeAssTime = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },

    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },

    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加订单指派";
    },

    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getAllocate(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改订单指派";
      });
    },

    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateAllocate(this.form).then(() => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addAllocate(this.form).then(() => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },

    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除订单指派编号为"' + ids + '"的数据项？').then(() => {
        return delAllocate(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      });
    },

    /** 导出按钮操作 */
    handleExport() {
      this.download('order/allocate/export', {
        ...this.queryParams
      }, `allocate_${new Date().getTime()}.xlsx`);
    },
  }
}
</script>

<style scoped>

/* 统一表格每行高度 */
::v-deep .el-table__row {
  height: 40px;
}

/* 调整表格单元格内文字的垂直居中与行高匹配 */
::v-deep .el-table__cell {
  padding-top: 0;
  padding-bottom: 0;
  line-height: 40px; /* 之前是 40 px，修正空格 */
}

.app-container.allocate-fixed {
  min-height: calc(100vh - 84px);
  padding: 20px;
  background-color: #f5f7fa;
  box-sizing: border-box;
  overflow-y: auto;
}

.main-content {
  display: flex;
  align-items: stretch; /* 保证左右两栏高度一致 */
  height: 100%;
  gap: 20px;
}

.left-content {
  flex: 3;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
  /* 不用min-height，flex自动撑满 */
}

.right-toolbar {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* 关键：让订单列表卡片撑满左侧剩余高度，与右侧对齐 */
.order-list-card {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.order-table-wrapper {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.order-list-card .el-table {
  flex: 1;
  min-height: 0;
  height: 100%;
}

.pagination-wrapper {
  flex-shrink: 0;
}

.toolbar-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.toolbar-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 15px;
  min-height: 0;
}

.assign-actions {
  margin-top: auto;
  display: flex;
  gap: 10px;
}

.assign-actions .el-button {
  flex: 1;
}

.order-id-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  color: #409eff;
  font-weight: 500;
}

.order-id-cell:hover {
  color: #66b1ff;
  text-decoration: underline;
}

.project-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-text {
  color: #606266;
  font-size: 13px;
}

.multi-ellipsis {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
  white-space: normal;
  cursor: pointer;
  min-height: 44px; /* 2行高度占位，假设每行22px，可根据实际字体微调 */
  line-height: 22px;
  max-height: 44px;
}

@media (max-width: 1400px) {
  .main-content {
    flex-direction: column;
    height: auto;
  }

  .left-content,
  .right-toolbar {
    width: 100%;
    min-width: 0;
    height: auto;
  }

  .order-list-card,
  .toolbar-card {
    height: auto;
    min-height: 0;
  }
}

@media (max-width: 768px) {
  .app-container.allocate-fixed {
    padding: 10px;
  }

  .main-content {
    gap: 10px;
  }

  .assign-actions {
    flex-direction: column;
    gap: 10px;
  }
}

/* 让el-descriptions撑满el-card body且无padding */
::v-deep .search-result-card .el-card__body {
  padding: 0 !important;
}

::v-deep .search-result-card .el-descriptions {
  width: 100%;
}

::v-deep .assign-result-card .el-card__body {
  padding: 0 !important;
}

::v-deep .assign-result-card .el-descriptions {
  width: 100%;
}

.assign-form-beauty .el-input__inner {
  background: #f5f7fa;
  border-radius: 8px;
  border: 1px solid #e4e7ed;
  transition: border-color 0.2s;
  font-size: 14px;
  padding: 7px 36px 7px 32px;
  box-shadow: none;
}

.assign-form-beauty .el-input__inner:focus {
  border-color: #409eff;
  background: #fff;
}

.assign-form-beauty .el-form-item {
  margin-bottom: 10px;
}

.assign-form-beauty .el-input__prefix {
  color: #bfcbd9;
  left: 8px;
}

.assign-form-beauty .el-input__suffix {
  right: 8px;
}

.assign-form-beauty .el-form-item__label {
  color: #606266;
  font-weight: 500;
  font-size: 14px;
  padding-right: 8px;
}

.single-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  max-width: 100%;
  cursor: pointer;
}

::v-deep .assign-form-card .el-card__body {
  padding-bottom: 6px !important;
  padding-top: 12px !important;
  padding-left: 18px !important;
  padding-right: 18px !important;
}

.search-form-grid .el-form-item {
  margin-bottom: 12px;
}

.search-btn-group {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  height: 100%;
}

.search-btn-col {
  display: flex;
  align-items: flex-end;
}

@media (max-width: 1200px) {
  .search-btn-group {
    justify-content: flex-start;
  }
}

</style>
